package entity;

import java.math.BigDecimal;

public class Cat {
    private int id;
    private String catName;
    private String engName;
    private String catImg;
    private BigDecimal price;
    private String intro;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCatName() {
        return catName;
    }

    public void setCatName(String catName) {
        this.catName = catName;
    }

    public String getEngName() {
        return engName;
    }

    public void setEngName(String engName) {
        this.engName = engName;
    }

    public String getCatImg() {
        return catImg;
    }

    public void setCatImg(String catImg) {
        this.catImg = catImg;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    // 计算折后价
    public BigDecimal getPriceByDiscount(double discount){
        // 将double转换为BigDecimal
        BigDecimal dis=new BigDecimal(discount);
        // setScale：设置有效小数位,ROUND_HALF_UP：四舍五入
        return this.price.multiply(dis).setScale(2,BigDecimal.ROUND_HALF_UP);
    }
}
